Windows 環境配置案例分享
by Amy
配置方式:Windows 10 + Ubuntu 16.04 server @ VirtualBox + putty
- Local server @ docker in ubuntu
- GAE deployment @ docker in ubuntu
- Editor: vim
- Source code @ ubuntu
- git @ ubuntu
- 瀏覽器 @ Windows
我習慣 Linux 的作業環境,也比較熟悉 Linux 的系統配置,但因為 Linux 對筆電硬體裝置 (e.g. 指紋辨識、顯示卡、wifi 網路卡) 的相容性不好,所以採用了 Windows 做 host,用 VirtualBox 再跑一個 Ubuntu 起來,平時用 putty 連進 ubuntu 開發的配置。
VirtualBox Network Setting
辦公室 Wifi 的 dhcp server 不太正常,VirtualBox 如果跑橋接介面卡 (Bridge mode) 會拿不到 IP,我是改用 NAT 的方式運作。
因為是 NAT,所以要要把 VirtualBox 的 port forwarding 設定好:
- Local server 是在 Ubuntu 環境用 docker 跑起來,所以要轉 8080 和 8000 port
- putty 要連 ssh 進去,所以要把 22 port 轉出來
虛擬機器 > 設定值 > 網路 > 介面卡 1 頁面中,把介面卡 附加到 NAT,接著把 進階 的箭頭展開,點 連接阜轉送,會開一個新視窗,新增需要的規則。主機 IP 不用填,客體 IP 固定是 10.0.2.15。
putty
putty 很好用,不要用中文化的 pietty,我在 pietty 開 vim 所有排版都亂掉,看起來編碼還是有問題。
為什麼要在 ubuntu 跑 docker,不能在 Windows 跑 docker 嗎?
不能。牽涉到硬體資源分配的問題,host 不能同時跑兩個 hypervisor,因為我需要 virtual box,所以 docker 就只能藏到 ubuntu 裡面。
如果可以再來一次,會嘗試什麼新的配置?
聽說 VMWare 效能比 VirtualBox 好,如果下次要裝桌面板的 ubuntu 就會改用 VMWare,因為 VirtualBox 的虛擬桌面不能縮放畫面。
或者直接把 ubuntu 也丟到 docker 裡面,這樣就可以直接用 Windows 跑 docker,開一個 container 跑 ubuntu,再開一個跑 local server。
好用 config 分享
alias @ bashrc
# deploy 結束後,把 junyiacademy/* 快速還原的指令
alias jclean='sudo git reset --hard && sudo git clean -dfx && \
cd javascript/perseus-package && sudo git reset --hard && \
sudo git clean -dfx && cd - && \
cd khan-exercises && sudo git reset --hard && sudo git clean -dfx && cd -'
gitconfig
# 記得把 ${USER} 換成自己的名子
[core]
editor = vim
excludesfile = ~/.gitignore
[user]
name = ${USER}
email = ${USER}@junyiacademy.org
[merge]
tool = vimdiff
[color]
ui = auto
diff = auto
status = auto
branch = auto
log = auto
[alias]
st = status
ci = commit
co = checkout
br = branch
df = diff
dc = diff --cached
ds = diff --name-status
ll = log --graph --decorate --pretty=oneline --abbrev-commit
la = log --graph --decorate --pretty=oneline --abbrev-commit --all
li = log --oneline --name-status --no-merges
ss = show --name-status
mt = mergetool
cp = cherry-pick
su = submodule update
[giggle]
main-window-maximized = true
main-window-geometry = 0x0+0+0
history-view-vpane-position = 535
file-view-vpane-position = 692
main-window-view = HistoryView
[push]
default = simple
screenrc
hardstatus alwayslastline "%{.Kw} %c | %-Lw%{Y}%n%f *%t*%{-}%+Lw | %{.Kw}%u"
# use utf8 as default encoding
defutf8 on
encoding utf8 utf8
# disable start up messages
startup_message off
# disable vbell
vbell off
# cap mouse action
termcapinfo xterm* ti@:te@
defscrollback 10000